<?php
// load configuration
require_once 'config.php';

require 'lib/base.php';

F3::set('AUTOLOAD','lib/');
F3::set('IMPORTS','pages/');

// sanitize variables
F3::set('POST',F3::scrub($_POST));
F3::set('GET',F3::scrub($_GET));

F3::set('DB',
	new DB(
		"mysql:host=$dbhost;port=3306;dbname=$dbname",
		$dbuser,
		$dbpass
	)
);

F3::set('E404','html/e404.html');

// start session
F3::get('SESSION.user_id');

// Index
F3::route('GET /','dummy.php');

// Users
F3::route('POST /users/','user_post.php');
F3::route('GET /users/','user_get_search.php');
F3::route('GET /all_users/','all_users_get.php');
F3::route('GET /users/@user_id','user_get.php');
F3::route('PUT /users/@user_id','user_put.php');
F3::route('POST /pfq/','pfq_get.php');
F3::route('PUT /pfq/','password.php');
F3::route('PUT /try/','aha.php');
F3::route('DELETE /delete_user/@user_id','user_delete.php');
// Sessions
F3::route('POST /session/','session_post.php');//log in
F3::route('DELETE /@user_id/session/','session_delete.php');//log off
// Follow
F3::route('POST /follow/','post_follow.php');
F3::route('GET /follow_me/','follow_me.php');
F3::route('GET /ifollow/','i_follow.php');
F3::route('DELETE /follow/@user_id','delete_follow.php');
// Badges
F3::route('GET /mybadge/','get_badge.php');
F3::route('GET /badge/@user_id','get_badge_user.php');
//Recipes
F3::route('POST /recipe/','recipe_post.php');
F3::route('POST /recipe/@recipe_id','recipe_post_try.php');
F3::route('GET /recipe/@recipe_id','recipe_info_get.php');
F3::route('PUT /recipe/@recipe_id','recipe_put.php');
F3::route('GET /recipe/peopletried/@recipe_id','recipe_tried_get.php');
F3::route('GET /recipe/','recipe_get_search.php');
F3::route('GET /all_recipes/@user_id','recipe_get_all.php');
F3::route('GET /all_recipes/@user_id/@tag_id','recipe_get_by_tag.php');
F3::route('DELETE /recipe/@recipe_id','recipe_delete.php');
F3::route('POST /email/','recipe_email.php');

// Measurements
F3::route('GET /measurements/','measurements_get.php');

// Tags
F3::route('GET /tags/','tags_get.php');

// Ingredients
F3::route('GET /ingredients/','ingredients_get.php');

// Favorites
F3::route('POST /favorites/','favorites_post.php');
F3::route('DELETE /@user_id/favorites/@recipe_id','favorites_delete.php');
F3::route('GET /favorites/@user','favorites_get.php');

// Comments
F3::route('POST /comments/','comments_post.php');
F3::route('POST /@recipe_id/comments/','comments_delete.php');

// Rating
F3::route('POST /rating/','rating_post.php');

//Stats
F3::route('GET /stats/','stats_get.php');

// Latest Activity
F3::route('POST /latest_activity/','latest_activity_post.php');
F3::route('GET /latest_activity/@user_id/@view_id','latest_activity_get.php');

F3::run();

?>
